package com.glory.erp.invoice.order.bean;

import java.util.Date;
import java.util.HashMap;
import java.util.Map;
import java.util.Set;
import java.util.TreeMap;

import com.glory.erp.auth.emp.bean.Emp;
import com.glory.erp.invoice.orderdetail.bean.OrderDetail;
import com.glory.erp.invoice.supplier.bean.Supplier;
import com.glory.erp.util.FormatUtil;

/**
 * @Description: 订单
 * @Title: Order.java
 * @Author: 樊双峰
 * @Date: 2018年5月26日 下午10:46:16
 * @Version V1.0
 */
public class Order {

	/**
	 * 订单类型
	 */
	public static final Integer ORDER_ORDERTYPE_OF_BUY = 1;
	public static final Integer ORDER_ORDERTYPE_OF_SALE = 2;
	public static final Integer ORDER_ORDERTYPE_OF_RETURN_BUY = 3;
	public static final Integer ORDER_ORDERTYPE_OF_RETURN_SALE = 4;
	public static final String ORDER_ORDERTYPE_OF_BUY_VIEW = "采购";
	public static final String ORDER_ORDERTYPE_OF_SALE_VIEW = "销售";
	public static final String ORDER_ORDERTYPE_OF_RETURN_BUY_VIEW = "采购退货";
	public static final String ORDER_ORDERTYPE_OF_RETURN_SALE_VIEW = "销售退货";
	
	/**
	 * 状态
	 */
	public static final Integer ORDER_TYPE_OF_BUY_NO_CHECK = 111;
	public static final Integer ORDER_TYPE_OF_BUY_CHECK_PASS = 121;
	public static final Integer ORDER_TYPE_OF_BUY_CHECK_NO_PASS = 120;
	public static final Integer ORDER_TYPE_OF_BUY_BUYING = 131;
	public static final Integer ORDER_TYPE_OF_BUY_IN_STORE = 141;
	public static final Integer ORDER_TYPE_OF_BUY_COMPLETE = 199;
	public static final String ORDER_TYPE_OF_BUY_NO_CHECK_VIEW = "未审核";
	public static final String ORDER_TYPE_OF_BUY_CHECK_PASS_VIEW = "审核通过";
	public static final String ORDER_TYPE_OF_BUY_CHECK_NO_PASS_VIEW = "审核驳回";
	public static final String ORDER_TYPE_OF_BUY_BUYING_VIEW = "采购中";
	public static final String ORDER_TYPE_OF_BUY_IN_STORE_VIEW = "入库中";
	public static final String ORDER_TYPE_OF_BUY_COMPLETE_VIEW = "结单";
	
	/**
	 * 销售
	 */
	public static final Integer ORDER_TYPE_OF_SALE_NO_CHECK = 211;
	public static final Integer ORDER_TYPE_OF_SALE_CHECK_PASS = 221;
	public static final String ORDER_TYPE_OF_SALE_NO_CHECK_VIEW = "未审核";
	public static final String ORDER_TYPE_OF_SALE_CHECK_PASS_VIEW = "审核通过";
	
	public static final Map<Integer, String> orderTypeMap = new HashMap<Integer, String>();
	
	public static final Map<Integer, String> buyTypeMap = new TreeMap<Integer, String>();
	public static final Map<Integer, String> saleTypeMap = new TreeMap<Integer, String>();
	
	private static final Map<Integer, String> typeMap = new HashMap<Integer, String>();
	
	static{
		orderTypeMap.put(ORDER_ORDERTYPE_OF_BUY, ORDER_ORDERTYPE_OF_BUY_VIEW);
		orderTypeMap.put(ORDER_ORDERTYPE_OF_SALE, ORDER_ORDERTYPE_OF_SALE_VIEW);
		orderTypeMap.put(ORDER_ORDERTYPE_OF_RETURN_BUY, ORDER_ORDERTYPE_OF_RETURN_BUY_VIEW);
		orderTypeMap.put(ORDER_ORDERTYPE_OF_RETURN_SALE, ORDER_ORDERTYPE_OF_RETURN_SALE_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_NO_CHECK, ORDER_TYPE_OF_BUY_NO_CHECK_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_CHECK_PASS, ORDER_TYPE_OF_BUY_CHECK_PASS_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_CHECK_NO_PASS, ORDER_TYPE_OF_BUY_CHECK_NO_PASS_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_BUYING, ORDER_TYPE_OF_BUY_BUYING_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_IN_STORE, ORDER_TYPE_OF_BUY_IN_STORE_VIEW);
		buyTypeMap.put(ORDER_TYPE_OF_BUY_COMPLETE, ORDER_TYPE_OF_BUY_COMPLETE_VIEW);
		
		saleTypeMap.put(ORDER_TYPE_OF_SALE_NO_CHECK, ORDER_TYPE_OF_SALE_NO_CHECK_VIEW);
		saleTypeMap.put(ORDER_TYPE_OF_SALE_CHECK_PASS, ORDER_TYPE_OF_SALE_CHECK_PASS_VIEW);
		
		typeMap.putAll(buyTypeMap);
		typeMap.putAll(saleTypeMap);
	}
	
	/**
	 * id
	 */
	private Long uuid;

	/**
	 * 订单号
	 */
	private String orderNum;
	
	/**
	 * 创建时间
	 */
	private Long createTime;
	private Date createTimeMin;
	private Date createTimeMax;

	/**
	 * 创建时间 视图值
	 */
	private String createTimeView;
	
	/**
	 * 审核时间
	 */
	private Long checkTime;
	
	/**
	 * 审核时间 视图值
	 */
	private String checkTimeView;
	
	/**
	 * 结束时间
	 */
	private Long endTime;

	/**
	 * 结束时间 视图值
	 */
	private String endTimeView;
	
	/**
	 * 订单类型
	 */
	private Integer orderType;
	
	/**
	 * 订单类型 视图值
	 */
	private String orderTypeView;
	
	/**
	 * 状态：
	 * 未审核
	 * 审核通过
	 * 审核驳回
	 * 采购中
	 * 入库中
	 * 结单
	 */
	private Integer type;

	/**
	 * 状态 视图值
	 */
	private String typeView;
	
	/**
	 * 总数
	 */
	private Integer totalNum;
	private Integer totalNumMin;
	private Integer totalNumMax;
	
	/**
	 * 总价
	 */
	private Double totalPrice;
	private String totalPriceMin;
	private String totalPriceMax;

	/**
	 * 总价 视图值
	 */
	private String totalPriceView;
	
	/**
	 * 创建人 多对一
	 */
	private Emp creater;
	
	/**
	 * 审核人 多对一
	 */
	private Emp checker;
	
	/**
	 * 完成人 多对一
	 */
	private Emp completer;
	
	/**
	 * 供应商 多对一
	 */
	private Supplier supplier;
	
	/**
	 * 商品明细 一对多
	 */
	private Set<OrderDetail> orderDetails;
	
	public Order() {
	}

	public Long getUuid() {
		return uuid;
	}

	public void setUuid(Long uuid) {
		this.uuid = uuid;
	}

	public String getOrderNum() {
		return orderNum;
	}

	public void setOrderNum(String orderNum) {
		this.orderNum = orderNum;
	}

	public Long getCreateTime() {
		return createTime;
	}

	public void setCreateTime(Long createTime) {
		this.createTime = createTime;
		this.createTimeView = FormatUtil.formatDate(createTime);
	}

	public Long getCheckTime() {
		return checkTime;
	}

	public void setCheckTime(Long checkTime) {
		this.checkTime = checkTime;
		this.checkTimeView = FormatUtil.formatDate(checkTime);
	}

	public Long getEndTime() {
		return endTime;
	}

	public void setEndTime(Long endTime) {
		this.endTime = endTime;
		this.endTimeView = FormatUtil.formatDate(endTime);
	}

	public Integer getOrderType() {
		return orderType;
	}

	public void setOrderType(Integer orderType) {
		this.orderType = orderType;
		this.orderTypeView = orderTypeMap.get(orderType);
	}

	public Integer getType() {
		return type;
	}

	public void setType(Integer type) {
		this.type = type;
		this.typeView = typeMap.get(type);
	}

	public Integer getTotalNum() {
		return totalNum;
	}

	public void setTotalNum(Integer totalNum) {
		this.totalNum = totalNum;
	}

	public Double getTotalPrice() {
		return totalPrice;
	}

	public void setTotalPrice(Double totalPrice) {
		this.totalPrice = totalPrice;
		this.totalPriceView = FormatUtil.formatMoney(totalPrice);
	}

	public Emp getCreater() {
		return creater;
	}

	public void setCreater(Emp creater) {
		this.creater = creater;
	}

	public Emp getChecker() {
		return checker;
	}

	public void setChecker(Emp checker) {
		this.checker = checker;
	}

	public Emp getCompleter() {
		return completer;
	}

	public void setCompleter(Emp completer) {
		this.completer = completer;
	}

	public Supplier getSupplier() {
		return supplier;
	}

	public void setSupplier(Supplier supplier) {
		this.supplier = supplier;
	}

	public String getCreateTimeView() {
		return createTimeView;
	}

	public String getCheckTimeView() {
		return checkTimeView;
	}

	public String getEndTimeView() {
		return endTimeView;
	}

	public String getOrderTypeView() {
		return orderTypeView;
	}

	public String getTypeView() {
		return typeView;
	}

	public String getTotalPriceView() {
		return totalPriceView;
	}

	public Set<OrderDetail> getOrderDetails() {
		return orderDetails;
	}

	public void setOrderDetails(Set<OrderDetail> orderDetails) {
		this.orderDetails = orderDetails;
	}

	public Integer getTotalNumMin() {
		return totalNumMin;
	}

	public void setTotalNumMin(Integer totalNumMin) {
		this.totalNumMin = totalNumMin;
	}

	public Integer getTotalNumMax() {
		return totalNumMax;
	}

	public void setTotalNumMax(Integer totalNumMax) {
		this.totalNumMax = totalNumMax;
	}

	public String getTotalPriceMin() {
		return totalPriceMin;
	}

	public void setTotalPriceMin(String totalPriceMin) {
		this.totalPriceMin = totalPriceMin;
	}

	public String getTotalPriceMax() {
		return totalPriceMax;
	}

	public void setTotalPriceMax(String totalPriceMax) {
		this.totalPriceMax = totalPriceMax;
	}

	public Date getCreateTimeMin() {
		return createTimeMin;
	}

	public void setCreateTimeMin(Date createTimeMin) {
		this.createTimeMin = createTimeMin;
	}

	public Date getCreateTimeMax() {
		return createTimeMax;
	}

	public void setCreateTimeMax(Date createTimeMax) {
		this.createTimeMax = createTimeMax;
	}
}